<!--# layout("/templates/layout/layout_main.html",{"title":"编辑用户","nameSpace":"user_admin","breadcrumbs":[{"name":"用户管理","url":"user/list"},{"name":"用户编辑"}]}){ #-->
<div class="container-fluid">
	<div class="row">
		<div class="col-sm-8 col-sm-offset-2 ">
			<div  class="hr-20"></div>
			<form id="edit-form" class="form-horizontal" role="form" method="post">
				<input type="hidden" id="form-field-id" name="id" value="${obj.data.user.id!}"/>
				<div class="form-group">
					<label for="form-field-name" class="col-sm-2 control-label no-padding-right">用户名</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" id="form-field-name" name="name" data-type='required|userName' data-error='请输入正确的用户名'  placeholder="请输入用户名" value="${obj.data.user.name!}" />
					</div>
				</div>
				
				<div class="form-group">
					<label for="form-field-realname" class="col-sm-2 control-label no-padding-right">姓名</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" id="form-field-realname" name="realName" data-type='required' data-error='请输入用户真实姓名' placeholder="请输入真实姓名" value="${obj.data.user.realName!}" />
					</div>
				</div>
				<div class="form-group">
					<label for="form-field-phone" class="col-sm-2 control-label no-padding-right">联系电话</label>
					<div class="col-sm-5">
						<input type="text"  class="form-control" name="phone" id="form-field-phone" data-type='phone' data-error='请输入联系电话'  placeholder="请输入联系电话" value="${obj.data.user.phone!}" />
					</div>
				</div>
				
				<div class="form-group">
					<label for="form-field-email" class="col-sm-2 control-label no-padding-right">Email</label>
					<div class="col-sm-5">
						<input type="text"  class="form-control" name="email" id="form-field-email" data-type='email' data-error='请输入邮箱'  placeholder="请输入联系邮箱" value="${obj.data.user.email!}" />
					</div>
				</div>
				
				<div class="form-group">
					<label for="form-field-status" class="col-sm-2 control-label no-padding-right">用户状态</label>
					<div class="col-sm-5">
						<!-- <input  type="hidden" name="status" value="${obj.data.user.status!}"/> -->
						<label>
						<input name="statusSwitch" class="ace ace-switch ace-switch-5" 
						type="checkbox" ${obj.data.user.status! == "ACTIVED" ? "checked":""} /> 
						<span class="lbl"></span>
						</label>
					</div>
				</div>
				
				<!-- <div class="form-group">
					<label for="form-field-avatar" class="col-sm-2 control-label no-padding-right">用户头像</label>
					<div class="col-sm-3">
						<input type="file" name="avatar" accept="image/*" />
					</div>
				</div> -->
								
				
				<hr class="hr-30" />
				<div class="col-sm-12 center" >
					<button class="btn btn-sm" data-dismiss="modal"  type="button"  onclick="javascript:history.back();">
							<i class="ace-icon fa fa-times"></i>
							取 消
						</button>
	
						<button class="btn btn-sm btn-primary" type="button" onclick="editSave(this)">
							<i class="ace-icon fa fa-check"></i>
							保 存
						</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!--# } #-->
<script type="text/javascript">

$(function(){
	$('#edit-form input[type=file]').aceFileInput({
		style:'well',
		btn_choose:'用户头像上传',
		btn_change:null,
		no_icon:'ace-icon fa fa-cloud-upload',
		droppable:true,
		thumbnail:'large',
		allowExt:  ['jpg', 'jpeg', 'png'],
		before_change:function(files , droped){
			console.info(files);
			return true;
		},
		before_remove:function(){
			return true;
		}
	})
	
})

function editSave(btn){
	if ($('#edit-form').find('input,select').validation()) {//验证表单
		var myform = $('#edit-form') ;
		$.ajax({
			type:'post',
			url:getRootPath() + '/user/editSave.do',
			data:$('#edit-form').serialize(),
			dataType:'json',
			success:function(result) {
			if (result.operationState == 'SUCCESS') {
				location.href = getRootPath() + "/user/list";
			} else {
				layer.msg(result.data.reason);
			}
		}});
	}
}
</script>

  